﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdFdFieldEnginePE : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdFdFieldEnginePE(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdFdFieldEnginePE_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdFdFieldEnginePE obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdFdFieldEnginePE()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdFdFieldEnginePE(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdFdFieldEnginePE cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdFdFieldEnginePE_cast(OdRxObject.getCPtr(pObj));
			OdFdFieldEnginePE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFdFieldEnginePE_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFdFieldEnginePE_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFdFieldEnginePE_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdFdFieldEnginePE createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdFdFieldEnginePE_createObject();
			OdFdFieldEnginePE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdFdFieldEnginePE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool getSheetSetProperty(ref string propValue, string compName, string propName, OdDbDatabase pDb)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(propValue);
			IntPtr value = intPtr;
			bool result;
			try
			{
				bool flag = TD_DbPINVOKE.OdFdFieldEnginePE_getSheetSetProperty(this.swigCPtr, ref intPtr, compName, propName, OdDbDatabase.getCPtr(pDb));
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = flag;
			}
			finally
			{
				if (intPtr != value)
				{
					propValue = Marshal.PtrToStringUni(intPtr);
				}
			}
			return result;
		}

		public virtual bool parseObjProp(string prop, OdDbDatabase pDb, OdDbObjectId objId, ref string propName)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(propName);
			IntPtr value = intPtr;
			bool result;
			try
			{
				bool flag = TD_DbPINVOKE.OdFdFieldEnginePE_parseObjProp(this.swigCPtr, prop, OdDbDatabase.getCPtr(pDb), OdDbObjectId.getCPtr(objId), ref intPtr);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = flag;
			}
			finally
			{
				if (intPtr != value)
				{
					propName = Marshal.PtrToStringUni(intPtr);
				}
			}
			return result;
		}

		public virtual bool getObjPropValue(string propName, OdDbObjectId objId, OdFdFieldResult result)
		{
			bool result2 = TD_DbPINVOKE.OdFdFieldEnginePE_getObjPropValue(this.swigCPtr, propName, OdDbObjectId.getCPtr(objId), OdFdFieldResult.getCPtr(result));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result2;
		}

		public virtual OdDbDatabase getCurrentDb()
		{
			OdDbDatabase result = (OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdFdFieldEnginePE_getCurrentDb(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string getFileName(OdDbDatabase pDb)
		{
			string result = TD_DbPINVOKE.OdFdFieldEnginePE_getFileName(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getLispVariable(string lispVar, OdFieldValue fValue)
		{
			TD_DbPINVOKE.OdFdFieldEnginePE_getLispVariable(this.swigCPtr, lispVar, OdFieldValue.getCPtr(fValue));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
